package com.ybkj.o2o.zhuanxian.service.impl;

import com.ybkj.o2o.zhuanxian.entity.OrderRefuse;
import com.ybkj.o2o.zhuanxian.mapper.OrderRefuseMapper;
import com.ybkj.o2o.zhuanxian.service.OrderRefuseService;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class DefaultOrderRefuseService implements OrderRefuseService {

  @Autowired
  private OrderRefuseMapper orderRefuseMapper;

  @Override
  public List<OrderRefuse> findByParams(Long companyId, String orderNo, String employName,
      Date start, Date end, Integer limit, Integer rows, String appKey) {
    return orderRefuseMapper.findByParams(companyId, StringUtils.isNotBlank(orderNo) ? "%"
        + orderNo + "%" : null, StringUtils.isNotBlank(employName) ? "%" + employName + "%" : null,
        start, end, limit, rows, appKey);
  }

  @Override
  public Long countByParam(Long companyId, String orderNo, String employName, Date start, Date end,
      String appKey) {
    return orderRefuseMapper.countByParam(companyId, StringUtils.isNotBlank(orderNo) ? "%"
        + orderNo + "%" : null, StringUtils.isNotBlank(employName) ? "%" + employName + "%" : null,
        start, end, appKey);
  }

  @Override
  public OrderRefuse findByOrderIdAndAppKey(Long id, String appKey) {
    return orderRefuseMapper.findByOrderIdAndAppKey(id, appKey);
  }

  @Override
  public int insert(OrderRefuse orderRefuse) {

    return orderRefuseMapper.insert(orderRefuse);
  }



}
